<template>
    <view>
        <uv-loading-page v-if="loading" :loading="loading" loading-mode="circle" loadingText="加载中..."></uv-loading-page>
        <view v-else class="m-4">
            <uv-swiper :list="[notice.cover]" v-if="notice.cover"></uv-swiper>
            <view class="my-4">
                <uv-text bold :text="notice.title" :size="18"></uv-text>
                <view class="my-2 text-gray">
                    <uv-text color="inherit" :text="notice.createDate" align="right"></uv-text>
                </view>
            </view>
            <uv-divider :dashed="true"></uv-divider>
            <uv-parse :content="notice.theContent"></uv-parse>
        </view>

    </view>
</template>
<script setup lang="ts">
import { ref } from 'vue'
import { onLoad } from '@dcloudio/uni-app'
import { list } from '@/services/notice'

const loading = ref(true)
const notice = ref({
    title: '',
    cover: '',
    theContent: '',
    createDate: ''
})

onLoad((options) => {

    list({ id: options.id }).then(({ rows }) => {
        if (rows[0]) {
            notice.value = rows[0]
        } else {
            uni.showToast({
                title: '公告不存在',
                icon: 'none'
            })
        }
    }).catch(() => { }).finally(() => { loading.value = false })
})


</script>